// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import com.nokia.meego 1.0
import "Logic.js" as Logic


Page {
    id: splashPage
    orientationLock: appWindow.lockOrientation()

    tools: ToolBarLayout {
        id: tool
        visible: true

        Label {
            id: l_link
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
            font.pixelSize: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? 20 : 18
            font.italic: true
            opacity: 1
            text: "<a href='https://projects.developer.nokia.com/qnetman'>http://projects.developer.nokia.com/qnetman</a>"
            Behavior on opacity { NumberAnimation { duration: 1000 } }
            onLinkActivated: { Qt.openUrlExternally (link) }
        }
    }

    SequentialAnimation {
        id: mainSequentialAnim
        running: false
        PauseAnimation { duration: 1000 }
        NumberAnimation {
            target: textVersion;
            property: "x";
            from: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? 854+textVersion.width+50 : 480+textVersion.width+50
            to: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? -50-textVersion.width  : -50-textVersion.width
            duration: 1600;
            easing.type: Easing.OutInCubic
        }
        ParallelAnimation {
            NumberAnimation { target: textQNetMan; property: "opacity"; from:1; to:0; duration: 1000; }
            NumberAnimation { target: textQNetMan2; property: "opacity"; from:1; to:0; duration: 1000; }
            NumberAnimation { target: mainBackground; property: "opacity"; from:0; to:1; duration: 1000; }
            NumberAnimation { target: l_link; property: "opacity"; from:1; to:0; duration: 1000; }
        }

        onRunningChanged: {
            if( !running ) {
                Logic.openFile("MainPage.qml");
            }
        }
    }

    Rectangle {
        id: background
        anchors.centerIn: parent
        anchors.fill: parent
        color: "black"
    }

    Text {
        id: textQNetMan
        font.pixelSize: 68
        color: "lightblue"
        font.family: "Nokia Pure Text"
        font.bold: true
        text: "QNetMan"
        anchors.centerIn: parent
    }
    Text {
        id: textQNetMan2
        font.pixelSize: 68
        color: "lightblue"
        font.family: "Nokia Pure Text"
        font.bold: true
        text: "2"
        smooth: true
        anchors.left: textQNetMan.right
        anchors.leftMargin: 10
        anchors.verticalCenter: parent.verticalCenter
        opacity: 1
        scale: 0
        Behavior on scale {
            SequentialAnimation {
                PauseAnimation { duration: 600 }
                SpringAnimation { spring: 4; damping: 0.06 }
            }
        }
    }
    Text {
        id: textVersion
        text: qsTr("Version") + " " + appWindow.version
        font.pixelSize: 16
        color: "lightblue"
        font.family: "Nokia Pure Text"
        anchors.top: textQNetMan.bottom
        anchors.topMargin: 20
        x: 1000
    }

    Rectangle {
        id: mainBackground
        z: 10
        anchors.centerIn: parent
        anchors.fill: parent
        gradient: Gradient {
            GradientStop { position: 0.0; color: mytheme.grColor1 }
            GradientStop { position: 0.4; color: mytheme.grColor2 }
            GradientStop { position: 1; color: mytheme.grColor3 }
        }
        opacity: 0
    }


    MouseArea {
        id: maSplash
        anchors.fill: parent
        onClicked: {
            textQNetMan.visible = false
            textQNetMan2.visible = false
            mainBackground.opacity = 1
            mainSequentialAnim.running = false
            //Logic.openFile("MainPage.qml");
        }
    }

    Component.onCompleted: {
        mainSequentialAnim.running = true
        textQNetMan2.scale = 1
    }
}
